/**
 * These functions are used to create new fuses and dirs in a Mireau 
 * application. This script will automatically be included when you set the
 * constant 
 * 
 *    request.dev.b_INCLUDE_SYSTEMBAR 
 *
 * to 'true' in the file
 *
 *    /sys/app_constants.cfm
 *
 * @author  rens@joxx.nl
 * @version 1.0 - 2003.11.12
 */
function newSysDir()
{
  document.system.sysfuse.value = "previewadddir";

  while( true )
  {
    document.system.sDir.value = prompt( "Enter new (full) dirname", document.system.sGuiDir.value );
    document.system.sDir.value = document.system.sDir.value.trim();
    
    if(( document.system.sDir.value == null ) || 
       ( document.system.sDir.value == "null" ))
    {
      break;
    }

    if( document.system.sDir.value.length > 0 )
    {
      document.system.submit();
      break;
    }
  }
}

function newSysFuse()
{
  document.system.sysfuse.value  = "addfuse";
  document.system.sDir.value     = document.system.sGuiDir.value;
  
  /*
   * Make sure that we have at least ONE fusetype selected, otherwise we don't
   * know later on what files we have to create for the application.
   */
  _xCBArray = document.getElementsByName( "sType" );
  _bAtLeastOneChecked = false;
  
  for( i = 0; i < _xCBArray.length; i++ )
  {
    if( _xCBArray[i].checked )
    {
      _bAtLeastOneChecked = true;
    }
  }
  
  if( !_bAtLeastOneChecked )
  {
    alert( "Error:\n\nYou have to mark at least one checkbox before a new fuse can be generated." );
    return;
  }
  
  while( true )
  {
    document.system.sNewFuse.value = prompt( "Enter new fuse", "" );
    document.system.sNewFuse.value = document.system.sNewFuse.value.trim();
    
    if(( document.system.sNewFuse.value == null ) || 
       ( document.system.sNewFuse.value == "null" ))
    {
      break;
    }

    if( document.system.sNewFuse.value.length > 0 )
    {
      document.system.submit();
      break;
    }
  }
}